package com.dyh.quickdemo.demos.UnsafeFunc;

import sun.misc.Unsafe;

import java.lang.reflect.Field;

/*
@Author=Joey Wheeler
@Date=2020/10/26 17:32
*/
public class UnsafeHelper {
    private static final sun.misc.Unsafe UNSAFE;
    static {
        try {
            Field field = Unsafe.class.getDeclaredField("theUnsafe");
            field.setAccessible(true);
            UNSAFE = (Unsafe) field.get(null);
        } catch (Exception e) {
            throw new Error(e);
        }
    }

    public static Unsafe getUnsafe(){
        return UNSAFE;
    }
}
